package ptij.vocoder.baseModel.lp_analysis;

import ptolemy.actor.*;
import ptolemy.kernel.*;
import ptolemy.kernel.util.*;
import ptolemy.data.ObjectToken;
import ptolemy.data.type.*;

import ptij.vocoder.baseModel.*;

//////////////////////////////////////////////////////////////////////////
//// Autocorr
/**

@author Ivan Jeukens
@version v 0.1 07/08/2003
*/
public class Autocorr extends TypedAtomicActor {

    public Autocorr(CompositeEntity container, String name) throws
            IllegalActionException, NameDuplicationException {
        super(container, name);

        x = new TypedIOPort(this, "x", true, false);
        x.setTypeEquals(BaseType.OBJECT);

        wind = new TypedIOPort(this, "wind", true, false);
        wind.setTypeEquals(BaseType.OBJECT);

        r_h = new TypedIOPort(this, "r_h", false, true);
        r_h.setTypeEquals(BaseType.OBJECT);

        r_l = new TypedIOPort(this, "r_l", false, true);
        r_l.setTypeEquals(BaseType.OBJECT);

        norm = new TypedIOPort(this, "norm", false, true);
        norm.setTypeEquals(BaseType.OBJECT);
    }

    ///////////////////////////////////////////////////////////////////
    ////                     ports and parameters                  ////

    // Input ports
    public TypedIOPort x;
    public TypedIOPort wind;
    
    // Output Ports
    public TypedIOPort r_h;
    public TypedIOPort r_l;
    public TypedIOPort norm;

    ///////////////////////////////////////////////////////////////////
    ////                         public methods                    ////

    public void fire() throws IllegalActionException {
        ObjectToken obj = (ObjectToken) x.get(0);
        Short [] arg1 = (Short []) obj.getValue();
        
        obj = (ObjectToken) wind.get(0);
        Short [] arg2 = (Short []) obj.getValue();
        
        Short [] arg3 = new Short[Cnst.MP1];
        Short [] arg4 = new Short[Cnst.MP1];
        
        short r = autocorr(arg1, arg2, arg3, arg4);
        
        obj = new ObjectToken(arg3);
        r_h.broadcast(obj);
        
        obj = new ObjectToken(arg4);
        r_l.broadcast(obj);
        
        obj = new ObjectToken(new Short(r));
        norm.broadcast(obj);
    }

    ///////////////////////////////////////////////////////////////////
    ////                         private methods                   ////

    private short autocorr(Short [] x, Short [] wind, Short [] r_h,
            Short [] r_l) {
        
        
        
        return 0;
    }
        

    ///////////////////////////////////////////////////////////////////
    ////                         private variables                 ////

}

